package com.hj.authority.controller;

import com.alibaba.fastjson2.JSON;
import com.hj.authority.domain.query.ThreeReq;
import com.hj.authority.feign.RemoteStorageService;
import com.hj.response.resp.RestfulResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author hj
 * @Date 2023/5/20
 * @Description:
 */
@Tag(name = "storage/random接口")
@RestController
@RequestMapping("/remote/storage")
public class RemoteStorageController {

    @Resource
    private RemoteStorageService remoteStorageService;

    @Operation(summary = "one")
    @GetMapping("/random/one")
    public RestfulResult<String> randomOne(String name) {
        String one = remoteStorageService.randomOne(name);
        // 这个飘黄,想不到好的办法处理了...以后再看吧..
        RestfulResult<String> result = JSON.parseObject(one, RestfulResult.class);
        System.out.println(result);
        return result;
    }

    @Operation(summary = "two")
    @GetMapping("/random/two")
    public RestfulResult<String> randomTwo(String name) {
        RestfulResult<String> two = remoteStorageService.randomTwo(name);
        System.out.println(two);
        return two;
    }

    @Operation(summary = "three")
    @PostMapping("/random/three")
    public String randomThree(String name) {
        ThreeReq req=new ThreeReq();
        req.setName(name);
        String three = remoteStorageService.randomThree(req);
        RestfulResult<String> result = JSON.parseObject(three, RestfulResult.class);
        System.out.println(result);
        return result.getData();
    }

    @Operation(summary = "four")
    @PostMapping("/random/four")
    public String randomFour(String name) {
        ThreeReq req=new ThreeReq();
        req.setName(name);
        String four = remoteStorageService.randomFour(req);
        RestfulResult<String> result = JSON.parseObject(four, RestfulResult.class);
        System.out.println(result);
        return result.getData();
    }


}
